﻿using Common.AspNetCore;
using Common.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using StatsData.Api.Models.ReportQuery;
using StatsData.Api.Service;
using System;
using System.Threading.Tasks;

namespace StatsData.Api.Controllers
{
    [Route("api/ReportQuery")]
    public class ReportQueryController : ApiController
    {
        private readonly ReportQueryService reportQueryService;

        public ReportQueryController(ReportQueryService reportQueryService, IServiceProvider provider)
             : base(provider)
        {
            this.reportQueryService = reportQueryService;
        }

        [HttpPost, Route("GetEmpEffectiveOutputWorkhourOrderPage")]
        public async Task<ApiActionResult<ApiPagedResult<EmpWorkHourEffectiveOutputWorkhourModel>>> GetEmpEffectiveOutputWorkhourOrderPageAsync([FromBody] EmpWorkHourEffectiveOutputWorkhourPageParamModel request)
        {
            return await SafeExecuteAsync(async (param) =>
            {
                var page = await reportQueryService.GetEmpEffectiveOutputWorkhourOrderPageAsync(request);
                return page;
            });
        }
    }
}
